﻿using System;

namespace D3.Pathing
{
    public class CachedScene
    {
        public CachedScene(Scene scene)
        {
            if (scene.IsValid == false)
            {
                throw new ArgumentException("Scene is not valid (lacking navmesh!)");
            }

            NavMesh nm = scene.GetNavMesh();

            X = scene.X;
            Y = scene.Y;
            Z = scene.Z;
            SizeX = nm.SizeX;
            SizeY = nm.SizeY;
            SceneId = scene.Id;
            WorldId = scene.WorldId;
            Collisions = new NavMeshFlags[SizeX,SizeY];

            for (int x = 0; x < nm.SizeX; x++)
            {
                for (int y = 0; y < nm.SizeY; y++)
                {
                    Collisions[x, y] = nm.GetFlags(y*nm.SizeY + x);
                }
            }
        }

        public NavMeshFlags[,] Collisions { get; private set; }
        public float X { get; private set; }
        public float Y { get; private set; }
        public float Z { get; private set; }
        public int SizeX { get; set; }
        public int SizeY { get; set; }
        public uint SceneId { get; private set; }
        public uint WorldId { get; private set; }
    }
}